package com.peng.mybatis.transaction.jdbc;

import cn.hutool.db.transaction.TransactionLevel;
import com.peng.mybatis.transaction.Transaction;
import com.peng.mybatis.transaction.TransactionFactory;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class JdbcTransactionFactory implements TransactionFactory {

    @Override
    public Transaction newTransaction(Connection connection) throws SQLException {
        return new JdbcTransaction(connection);
    }

    @Override
    public Transaction newTransaction(DataSource dataSource, TransactionLevel level, boolean autoCommit) throws SQLException {
        return new JdbcTransaction(dataSource, level, autoCommit);
    }

}
